package com.showcai.service.impl;

import com.github.pagehelper.PageInfo;
import com.showcai.dao.MessageBoardMapper;
import com.showcai.module.MessageBoard;
import com.showcai.myRunTime.MyRunTimeExcption;
import com.showcai.service.MessageBoardService;
import com.showcai.service.ServiceBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by Baggio on 2018-9-5.
 */
@Service
public class MessageBoardServiceImpl extends ServiceBase implements MessageBoardService {
    @Autowired
    MessageBoardMapper messageBoardMapper;
    @Override
    public void addMessageBoard(MessageBoard messageBoard) throws MyRunTimeExcption {
        messageBoard.setStatus(MessageBoard.STATUS_VALID);
        messageBoard.setCreateTime(new Date());
        messageBoardMapper.insertMessageBoard(messageBoard);
    }

    @Override
    public PageInfo getMessageBoardList(Map<String, String> map) throws MyRunTimeExcption {
       List<MessageBoard> messageBoardList= messageBoardMapper.getMessageBoardList(map);
       PageInfo<MessageBoard> pageInfo=new PageInfo<MessageBoard>(messageBoardList);
        return pageInfo;
    }
}
